package com.yy.train.ticket.train.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yy.train.ticket.train.entity.TtLineStationEntity;
import com.yy.train.ticket.train.service.TtLineStationService;
import com.yy.train.ticket.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;



/**
 * 列车线路
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2023-09-27 10:03:48
 */
@RestController
@RequestMapping("tt/lineStation")
public class TtLineStationController {
    @Autowired
    private TtLineStationService ttLineStationService;

    /**
     * 列表
     */
    @GetMapping("/list/{lineId}")
    public R list(@PathVariable("lineId")  Long lineId){
        return this.ttLineStationService.listStation(lineId);
     //   return R.ok(this.ttLineStationService.list(Wrappers.<TtLineStationEntity>lambdaQuery().eq(TtLineStationEntity::getLineId,lineId)));

    }


    /**
     * 信息
     */
    @RequestMapping("/info/{lineStationId}")
    public R info(@PathVariable("lineStationId") Long lineStationId){
		TtLineStationEntity ttLineStation = ttLineStationService.getById(lineStationId);
        return R.ok(ttLineStation);/**/


    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody TtLineStationEntity ttLineStation){
		ttLineStationService.save(ttLineStation);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody TtLineStationEntity ttLineStation){
		ttLineStationService.updateById(ttLineStation);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody List<Long> lineStationIds){
		ttLineStationService.removeByIds(lineStationIds);

        return R.ok();
    }

}
